﻿using System;

namespace HashFoo.Rest.Common
{
    /// <summary>
    /// Interface to thread/UI dispatching needs on the client.
    /// </summary>
    public interface IDispatcher
    {
        /// <summary>
        /// Dispatch a worker onto the UI thread.
        /// </summary>
        /// <param name="worker">The worker to execute.</param>
        /// <param name="force">If true, forces the call to be invoked, else: invokes if <see cref="RequiresInvoke"/> is true, else executes the worker on the current thread.</param>
        void BeginInvoke(Action worker, bool force = false);

        /// <summary>
        /// True if an invoke is needed to get back the dispatchers source thread (the UI thread).
        /// </summary>
        bool RequiresInvoke { get; }
    }
}